package main

import (
	"fmt"
	"net/http"
	"net/rpc"
)

type AddRequest struct {
	Left  int
	Right int
}

type AddResponse struct {
	Result int
}

type Calc struct {
}

func (c *Calc) Add(req AddRequest, resp *AddResponse) error {
	fmt.Println("calc.add")
	resp.Result = req.Left + req.Right
	return nil
}

func main() {
	rpc.Register(&Calc{})
	rpc.HandleHTTP()
	//listener, _ := net.Listen("tcp", "0.0.0.0:8888")
	http.ListenAndServe("0.0.0.0:8888", nil)
}
